<?php // a_authord.php -- Admin view Author Details

require_once('./inc/inc.common.php');
$tmpl 		= new mvTemplate();
$tmpl->page_title('View Author');

if(!isset($_SESSION['user']) || !$_SESSION['user']->isAdmin){
	mvError::userError('Not Authorized', 'You are not authorized to view that page.');
	header('location: index.php');
	die();
}

$a = author::load($_REQUEST['aid']);

// articles count
$sql = "SELECT SUM(Approved = 'N') as pending, SUM(Approved = 'Y') as approved, count(*) as cnt from articles WHERE AuthorID=?";
$parms = array($a->id);
$query = $GLOBALS['db']->prepare_execute($sql, $parms);
$stats = $query->fetch();

$tmpl->assign('author', $a);
$tmpl->assign('stats', $stats);

$tmpl->page_display('a_authord.tpl');
?>